Fast-acting Costas loop

ABSTRACT

A system and method using a Costas loop to effect accelerated convergence with minimal system complexity. The system comprises an in-phase-limiter and a quadrature-phase limiter, operatively coupled to an EXCLUSIVE-OR gate, for exclusively-ORing an in-phase-sign signal and a quadrature-phase-sign signal to output a first error signal, responsive to the signals having same signs, or a second error signal, responsive to the signals having different signs. An AGC circuit, operatively coupled to an output of the EXCLUSIVE-OR gate, increases and decreases a voltage level of an AGC signal responsive to two consecutive first or second error signals and consecutive dissimilar error signals, respectively. A voltage-controlled oscillator, operatively coupled to an output of the AGC circuit and responsive to the increased or decreased voltage level, changes the frequency of a voltage-controlled-oscillator output signal.

RELATED PATENTS

This patent is a continuation application under 37 C.F.R. § 1.53 of U.S. patent application having Ser. No. 08/873,253, and filing date of Jun. 11, 1997, which issued as U.S. Pat. No. 5,956,375 on Sep. 21, 1999, entitled FAST-ACTING COSTAS LOOP by the inventor EMMANUEL KANTERAKIS, which is a continuation of U.S. patent application entitled, FAST-ACTING COSTAS LOOP having Ser. No. 08/578,422 and filing date Dec. 26, 1995, which issue as U.S. Pat. No. 5,640,425 with issue date Jun. 17, 1997. The benefit of the earlier filing date of the parent patent applications is claimed pursuant to 35 U.S.C. § 120.

BACKGROUND OF THE INVENTION

This invention relates to Costas loops, and more particularly to an improvement to the Costas loop which increases the rate of tracking a frequency.

DESCRIPTION OF THE RELEVANT ART

In consumer products the cost must be minimized. For radio transmitter and receiver applications, crystals, and not frequency synthesizers, typically are used. Crystals are cut to thirty parts per million (PPM) to reduce cost, rather than one or five parts per million as found in a military type system. Hence, at 2000 MHz, for example, the frequencies between a transmitter and a receiver may differ by 60 kHz. In a cordless phone application, if a handset were taken into extreme hot or cold temperatures it may not be possible to compensate for the frequency deviation, unless a Costas loop is used. The frequency controlling element in that loop is a crystal.

Current designs of Costas loops are implemented using different configurations of the arm filters and various orders for the loop or lowpass filter. Thresholding of the in-phase arm is often followed by a sign change, using a data-aided feedback configuration, aimed at simplifying the hardware and increasing the acquisition speed. The loop filter has often remained as a second order filter which occasionally switches to a third order filter after the Costas loop has been locked. These types of structures are typically complex and very slow in convergence, especially for large frequency offsets. It is a purpose of this invention to accelerate the convergence while keeping the overall system complexity and associated cost to a minimum. A Costas loop as defined here as a type of phase locked loop which controls a voltage controlled oscillator, can closely follow the phase of the incoming signal. However, this invention applies to both frequency locked loops and/or phase locked loops which are closed-loop, feedback systems.

SUMMARY OF THE INVENTION

A general object of the invention is to decrease cost and reduce the frequency acquisition time of a Costas loop.

Another object of the invention is a fast Costas loop which can operate in conditions of extreme heat and cold.

An additional object of the invention is an improved Costas loop which can increase the rate of acquisition, depending on received signals.

According to the present invention, as embodied and broadly described herein, an improvement to a Costas loop includes an in-phase limiter, a quadrature-phase limiter, an EXCLUSIVE-OR (XOR) gate, an EXCLUSIVE-NOR gate, and a register. The Costas loop further includes a voltage-controlled oscillator (VCO), an in-phase-mixer, a quadrature-phase mixer, an in-phase-matched filter, a quadrature-phase-matched filter, a fixed gain (FG) circuit, and a loop filter. As is well known in the art, the voltage-controlled oscillator, in response to changes in an applied voltage or current from the loop filter, changes a frequency of a VCO-output signal. The voltage-controlled oscillator controls the frequency in response to the voltage or current applied at the input of the voltage-controlled oscillator.

The in-phase mixer generates an in-phase-baseband signal from a received spread-spectrum signal; the quadrature-phase mixer generates a quadrature-phase-baseband signal from the received spread-spectrum signal. The in-phase-matched filter removes a chipping sequence from the in-phase-baseband signal, thereby generating an in-phase-detected signal. The quadrature-phase-matched filter removes the chipping sequence from the quadrature-phase-baseband signal, thereby generating a quadrature-phase-detected signal.

The in-phase limiter generates an in-phase-sign signal from the in-phase-detected signal. The quadrature-phase limiter generates a quadrature-phase-sign signal from the quadrature-phase-detected signal.

The EXCLUSIVE-OR gate exclusively-ors the in-phase-sign signal with the quadrature-phase-sign signal. When the in-phase-sign signal and the quadrature-phase-sign signal have the same signs, then the EXCLUSIVE-OR gate outputs a first error signal. When the in-phase-sign signal and the quadrature-phase-sign signal have different signs, then the EXCLUSIVE-OR gate outputs a second error signal. The fixed-gain circuit, in response to the first error signal, increases the first error signal which in turn changes the frequency of the VCO-output signal after being filtered by the loop filter. When the second error signal is present, the fixed-gain circuit decreases the second error signal which in turn changes the frequency of the VCO-output signal after being filtered by the loop filter.

The EXCLUSIVE-NOR gate compares a present value and a previous value from the first EXCLUSIVE-OR gate. Thus, a signal having a previous value representing a prior output of the EXCLUSIVE-OR gate is stored in a register. The present value is the current output of the EXCLUSIVE-OR gate. When the present value and the previous value are the same, then an XNOR-output signal from the EXCLUSIVE-NOR (XNOR) gate causes an increase in the gain of the AGC circuit. When the two signals are different, then the XNOR-output signal from the EXCLUSIVE-NOR gate causes a decrease in the gain of the ACC circuit.

The present invention also includes a method for improving the performance of a Costas loop. The method includes the steps of generating an in-phase-sign signal from the in-phase-detected signal and generating a quadrature-phase-sign signal from the quadrature-phase-detected signal. A first error signal is generated in response to the in-phase-sign signal and the quadrature-phase-sign signal having the same sign. A second error signal is generated in response to the in-phase-sign signal and the quadrature-phase-sign signal having different signs.

The AGC gain of the AGC circuit increases when two consecutive first error signals or two consecutive second error signals are present and decreases when two consecutive error signals are either a first error signal followed by a second error signal or a second error signal followed by a first error signal. The frequency of the voltage-controlled oscillator changes, depending on fluctuations in the voltage or current level of the AGC signal filtered by the loop filter responsive to the error signals.

Additional objects and advantages of the invention are set forth in part in the description which follows, and in part are obvious from the description, or may be learned by practice of the invention. The objects and advantages of the invention also may be realized and attained by means of the instrumentalities and combinations particularly pointed out in the appended claims.

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate preferred embodiments of the invention, and together with the description serve to explain the principles of the invention.

FIG. 1 is a block diagram of a fast-acting Costas loop according to the present invention;

FIG. 2 is a block diagram of a fast-acting Costas loop with a register and an automatic gain control circuit;

FIG. 3 illustrates frequency offset estimation using a Costas loop without an adaptive gain control;

FIG. 4 illustrates frequency offset estimation using a Costas loop with an adaptive gain control;

FIG. 5 illustrates frequency offset estimation using a Costas loop with an adaptive gain control, using the same system parameters as those in FIG. 4, with the minimum loop gain reduced; and

FIG. 6 illustrates frequency offset estimation using a Costas loop with an adaptive gain control, with the same system parameters as those of FIG. 4, with the maximum and the minimum loop gains increased and decreased, respectively.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

Reference now is made in detail to the present preferred embodiments of the invention, examples of which are illustrated in the accompanying drawings, wherein like reference numerals indicate like elements throughout the several views.

The present invention broadly provides an improvement to a Costas loop. The Costas loop is well known in the art and, as shown in FIG. 1, includes a voltage-controlled oscillator (VCO) 35, a fixed gain circuit 37, an in-phase mixer 31, a quadrature-phase mixer 33, an in-phase-matched filter 32, a quadrature-phase-matched filter 34, and other circuitry such as loop filter 36, which typically is a lowpass filter. The voltage-controlled oscillator 35 is coupled through the loop filter 36 to the fixed gain circuit 37. The output of the voltage-controlled oscillator 35 is coupled to the in-phase mixer 31 and the quadrature-phase mixer 33. The in-phase mixer 31 is coupled through a lowpass filter 38 to the in-phase-matched filter 32, and the quadrature-phase mixer 33 is coupled through a lowpass filter 39 to the quadrature-phase-matched filter 34.

The Costas loop uses the in-phase mixer 31 to generate an in-phase-baseband signal by mixing a received spread-spectrum signal with cos ω_(o) t from the voltage-controlled oscillator, and a quadrature-phase mixer 33 to generate a quadrature-phasebase-band signal by mixing the received spread-spectrum signal with sin ω_(o) t from the voltage-controlled oscillator. The in-phase-matched filter 32 removes a chipping sequence from the in-phase-base-band signal, thereby generating an in-phase-detected signal. The quadrature-phased-matched filter 34 removes the chipping sequence from the quadrature-phase-baseband signal, thereby generating a quadrature-phase-detected signal.

The improvement to the Costas loop includes first generating means, second generating means, and third generating means. The first generating means is operatively coupled to the in-phase-matched filter 32 and the second generating means is operatively coupled to the quadrature-phase-matched filter 34. The third generating means is operatively coupled to the first generating means and to the second generating means.

The first generating means generates an in-phase-sign signal from the in-phase-detected signal. The second generating means generates a quadrature-phase-sign signal from the quadrature-phase-detected signal. The third generating means, in response to the in-phase-sign signal and the quadrature-phase-sign signal having the same sign, outputs a first error signal. In response to the in-phase-sign signal and the quadrature-phase-sign signal having different signs, the third generating means outputs a second error signal. The terms in-phase-sign signal and quadrature-phase-sign signal, as used herein, represent signals which indicate the sign, i.e., polarity, of the in-phase-detected signal and the quadrature-phase-detected signal, respectively.

The fixed gain circuit 37 is operatively coupled to the third generating means. In response to the first error signal, the fixed-gain circuit 37 increases the first error signal. As a consequence, the increased first error signal at the output of the fixed-gain circuit 37, can change the frequency of the voltage-controlled oscillator 35. In response to the second error signal, the fixed-gain circuit 37 decreases the second error signal. As a result, this changes the frequency of the voltage-controlled oscillator 35. The circuits can be equivalently designed such that either an increase or a decrease in the voltage or current level causes either an increase or a decrease in the frequency of the voltage-controlled oscillator signal.

In the exemplary arrangement shown in FIG. 1, the first generating means is embodied as an in-phase limiter 41, the second generating means is embodied as a quadrature-phase limiter 42, and the third generating means is embodied as an EXCLUSIVE-OR gate 43. The EXCLUSIVE-OR gate 43 is operatively coupled to the in-phase limiter 41 and to the quadrature-phase limiter 42. Each of the first generating means and the second generating means, by way of example, is shown as a limiter, and may be either a hard limiter, a soft limiter or other device which can determine a sign of the in-phase-detected signal or the quadrature-phase-detected signal, respectively. The third generating means is illustratively shown as an EXCLUSIVE-OR gate. The third generating means alternatively may be embodied from EXCLUSIVE-NOR gates, AND gates, OR gates, and combinations of other logic gates, as is well known in the art. See Schilling, DIGITAL INTEGRATED ELECTRONICS (1977).

The EXCLUSIVE-OR gate 43 is operatively coupled to the in-phase limiter 41 and the quadrature-phase limiter 42. The EXCLUSIVE-OR gate 43 exclusively-ors the in-phase-sign signal with the quadrature-phase-sign signal. Thus, the EXCLUSIVE-OR gate 43 essentially multiplies the sign signals together to determine as an output whether there is agreement between the signs or disagreement. More particularly, in response to the in-phase-sign signal and the quadrature-phase-sign signal having the same signs, the EXCLUSIVE-OR gate 43 outputs a first error signal. The first error signal, as used herein, indicates that the signs of the in-phase-sign signal and the quadrature-phase-sign signal are the same.

When the in-phase-sign signal and the quadrature-phase-sign signal have different signs, then the EXCLUSIVE-OR gate 43 outputs a second error signal. The second error signal, as used herein, indicates that the in-phase-sign signal and the quadrature-phase-sign signal have different signs.

The fixed gain circuit 37 is operatively coupled to the EXCLUSIVE-OR gate 43. When the first error signal is present at the output of the EXCLUSIVE-OR gate 43 and at the input of the fixed-gain circuit 37, then the fixed-gain circuit 37 increases the first error signal. This, as a consequence, changes the frequency of the voltage-controlled oscillator 35, since the fixed-gain circuit output signal is applied at the input of the voltage-controlled oscillator 35 after being filtered by the loop filter 36. When the second error signal is present at the output of the EXCLUSIVE-OR gate 43, the fixed-gain circuit 37 decreases the second error signal. This, as a consequence, can also change the frequency of the voltage-controlled oscillator 35, albeit in a different direction.

As shown in FIG. 2, the present invention also may include an EXCLUSIVE-NOR gate 44, a register 45, and a low pass filter 46. The EXCLUSIVE-NOR gate 44 has a first input operatively coupled to an output of the EXCLUSIVE-OR gate 43, and a second input operatively coupled to the output of the register 45. The register 45 has an input operatively coupled to the output of the EXCLUSIVE-OR gate 43.

The EXCLUSIVE-NOR gate 44 can be used to change the AGC gain, that is, how much the AGC circuit 47 changes the first and second error signals when applied to its input. Thus, the register 45 stores the previous value outputted from the EXCLUSIVE-OR gate 43. The EXCLUSIVE-NOR gate 44 compares the output of the EXCLUSIVE-OR gate 43 and the previous value outputted from the EXCLUSIVE-OR gate 43, which was stored in the register 45. When the output of the EXCLUSIVE-OR gate 43 and the signal stored in the register 45 as the previous value have the same value, then the output of the EXCLUSIVE-NOR gate 44 is a first rate signal indicating to increase the gain of the AGC circuit 47. When the output of the EXCLUSIVE-OR gate 43 and the signal stored in the register 45 as the previous value have different values, namely different signs, then the EXCLUSIVE-NOR gate 44 outputs a second rate signal indicating to decrease the gain of the AGC circuit 47.

Additional registers and EXCLUSIVE-NOR gates may be added to the EXCLUSIVE-NOR gate 44, for comparing previous values and determining various slopes and gain changes of the AGC circuit 47, as desired by a particular design. These variations would be obvious to those skilled in art with understanding of the present invention.

In use of the fast-acting Costas loop of the present invention, the input is a BPSK signal, with g(t) being a pseudo random sequence. The values of ω₁ and ω₂ can differ by a large amount. The lowpass filters remove the sum frequency of ω₁ +ω₂ +θ(t). The matched filters (MF) remove the pseudo noise sequence g(t), leaving the results, d(t)sin(ω₂ t+θ(t)) and d(t) cos (ω₂ t+θ(t)), where d(t) is the data modulation sequence. The two sign circuits extract the sign bit, remembering that this is a digital matched filter. Using the sign bit rather than, say, a 4-bit word, saves gates in the application specific integrated circuit (ASIC). The outputs are EXCLUSIVE-OR, which is mathematically equivalent to a multiplication. Thus, in the ASIC the gate count is increased by only one EXCLUSIVE-OR gate circuit in building the Costas loop. The output of the EXCLUSIVE-OR gate is amplified by the fixed gain circuit 37 before being filtered by the loop filter 36. This is often a proportional plus integral but could have any reasonable shape. The design of such filters is well known in the art and not part of the present invention. Rather, the key elements of the present invention are the blocks depicted in FIGS. 1 and 2, previously discussed.

Looking to FIG. 2, the received signal is first band-pass filtered to remove out-of-band noise and then down-converted to its in-phase and quadrature components using the locally estimated carrier frequency ω₀. The resulting signals x_(c) (t) and x_(s) (t) are lowpass-filtered to remove second order harmonics resulting in y_(c) (t) and y_(s) (t) for the in-phase and quadrature arms, respectively. These two components are then each filtered by a filter matched to the modulating waveform. An A/D converter can be used if the matched filter operation is to be carried out digitally. The outputs of the matched filters are sampled at the peaks at the symbol rate using a sample-and-hold (S/H) circuit. The signs of the S/H outputs are fed to an exclusive-or (XOR) gate to form the error signal e(t). Normally, this error signal is used to drive a voltage-controlled-oscillator (VCO) after being multiplied by a gain factor K and filtered by the loop filter. The gain factor is used to control the rate of convergence and the loop filter to remove the noise terms from the signal e(t).

According to the present invention, both the in-phase and the quadrature-phase outputs are hard limited and then compared using an XOR gate to form the error signal and using an adaptive gain control subsystem to control the convergence rate of the loop. The adaptive gain control subsystem is comprised of a circuit which compares the current and previous error signals, with the previous error signal delayed by one symbol, and having an output that controls an adaptive gain control (AGC) amplifier after being filtered by a lowpass filter. The comparison circuit output is high when both inputs are the same. The AGC amplifier increases the gain when the controlling input is high and decreases the gain when the controlling input is low. The upper and lower limits of the AGC amplifier, as well as the bandwidth and DC gain of the lowpass filter, are design variables.

The overall fast acting Costas loop has been simulated and its performance compared to a Costas loop with the adaptive gain control removed. FIG. 3 shows the locally estimated frequency offset using the Costas loop of FIG. 1 with a fixed gain and a given set of system parameters. Using the same system parameters, the adaptive gain control 47 of FIG. 2 was inserted with a particular minimum gain, maximum gain, and amount of filtering. The resulting frequency offset estimate is shown in FIG. 4. Since the minimum loop gain controls the frequency offset estimation error by increasing the filtering of e(t), and the maximum loop gain controls the convergence rate, two additional graphs were constructed showing this effect. In FIG. 5, the minimum gain was reduced with all other system parameters set to those of FIG. 4. The decrease of the frequency estimation error is evident. In FIG. 6, the parameters of FIG. 5 were used with the maximum gain increased. However, the convergence rate did not increase substantially, while the transients were somewhat increased. Further refinement of the algorithm should eliminate the transient effects and further reduce the steady-state frequency offset estimation error.

It will be apparent to those skilled in the art that various modifications can be made to the fast-acting Costas loop of the instant invention without departing from the scope or spirit of the invention, and it is intended that the present invention cover modifications and variations of the fast-acting Costas loop provided they come within the scope of the appended claims and their equivalents. 

I claim:
 1. An adaptive gain control subsystem for use with a Costas loop, comprising:first generating means for generating an in-phase-sign signal from an in-phase portion of a despread spread-spectrum signal; second generating means for generating a quadrature-phase-sign signal from a quadrature-phase portion of the despread spread-spectrum signal; third generating means, operatively coupled to said first generating means and to said second generating means, responsive to the in-phase-sign signal and to the quadrature-phase-sign signal having same signs, for outputting a first error signal; an adaptive-gain-control (AGC) amplifier, having a gain, operatively coupled to said third generating means, for amplifying the first error signal; a register, operatively coupled to an output of said third generating means, for storing a first previous error signal from said third generating means, with the first previous error signal previously occurring in time with respect to the first error signal; an EXCLUSIVE-NOR gate, having a first input operatively coupled to an output of said third generating means, a second input operatively coupled to an output of said register, responsive to the first error signal from said third generating means and the first previous error signal stored in said register, having a same value, for outputting a first value, and responsive to the first error signal from said third generating means and the first previous error signal stored in said register, having a different value, for outputting a second value; averaging means, coupled between said EXCLUSIVE-NOR gate and said AGC amplifier, for averaging a plurality of first values and second values, thereby generating a first averaged value; and said AGC amplifier, responsive to the first averaged value increasing, for increasing the gain of said AGC amplifier, said AGC amplifier, responsive to the first averaged value decreasing, for decreasing the gain of said AGC amplifier.
 2. The adaptive gain control subsystem as set forth in claim 1, wherein:said third generating means, responsive to the in-phase-sign signal and to the quadrature-phase-sign signal having different signs, for outputting a second error signal; said AGC amplifier, operatively coupled to said third generating means, for amplifying the second error signal; said register for storing a second previous error signal from said third generating means, with the second previous error signal previously occurring in time with respect to the second error signal; said EXCLUSIVE-NOR gate, responsive to the second error signal from said third generating means and the second previous error signal stored in said register having a same value, for outputting the third value, and responsive to the second error signal from said third generating means and a second previous error signal stored in said register having a different value, for outputting a fourth value; said averaging means for averaging a plurality of third values and fourth values, thereby generating a second averaged value; and said AGC amplifier, responsive to the second averaged value increasing, for increasing the gain of said AGC amplifier, said AGC amplifier, responsive to the second averaged value decreasing, for decreasing the gain of said AGC amplifier.
 3. An adaptive gain control subsystem, for use with a Costas loop, comprising:an in-phase limiter for generating an in-phase-sign signal from an in-phase portion of a despread spread-spectrum signal; a quadrature-phase limiter for generating a quadrature-phase-sign signal from a quadrature-phase portion of the despread spread-spectrum signal; an EXCLUSIVE-OR gate, operatively coupled to said in-phase limiter and to said quadrature-phase limiter, for exclusive-ORing the in-phase-sign signal with the quadrature-phase-sign signal and, responsive to the in-phase-sign signal and the quadrature-phase-sign signal having same signs, for outputting a first error signal; an adaptive-gain-control (AGC) amplifier, having a gain, operatively coupled to an output of said EXCLUSIVE-OR gate, responsive to the first error signal for increasing gain; a register, operatively coupled to an output of said EXCLUSIVE-OR gate, for storing a first previous error signal from said EXCLUSIVE-OR gate, with the first previous first error signal previously occurring in time with respect to the first error signal; an EXCLUSIVE-NOR gate, having a first input operatively coupled to an output of said EXCLUSIVE-OR gate, a second input operatively coupled to an output of said register, responsive to the first error signal from said EXCLUSIVE-OR gate and the first previous error signal stored in said register having a same value, for outputting a first value, and responsive to the first error signal from said EXCLUSIVE-OR gate and the first previous error signal stored in said register having a different value, for outputting a second value; averaging means, coupled between said EXCLUSIVE-NOR gate and said AGC amplifier, for averaging a plurality of first values and second values, thereby generating a first averaged value; and said AGC amplifier, responsive to the first averaged value increasing, for increasing the gain of said AGC amplifier, said AGC amplifier, responsive to the first averaged value decreasing, for decreasing the gain of said AGC amplifier.
 4. The adaptive gain control subsystem as set forth in claim 3, wherein:said EXCLUSIVE-OR gate, responsive to the in-phase-sign signal and the quadrature-phase-sign signal having different signs, for outputting a second error signal; said AGC amplifier, responsive to the second error signal, for decreasing gain; said register for storing a second previous error signal from said EXCLUSIVE-OR gate; said EXCLUSIVE-NOR gate, responsive to the second error signal from said EXCLUSIVE-OR gate and the second previous error signal stored in said register having a same value, for outputting a first value, and responsive to the second error signal from said EXCLUSIVE-OR gate and the second previous error signal stored in said register having a different value, for outputting a fourth value; said averaging means for averaging a plurality of third values and fourth values, thereby generating a second averaged value; and said AGC amplifier, responsive to the second averaged value increasing, for increasing the gain of said AGC amplifier, said AGC amplifier, responsive to the second averaged value decreasing, for decreasing the gain of said AGC amplifier.
 5. In a Costas loop having a voltage-controlled oscillator coupled to a gain-control circuit, said voltage-controlled oscillator (VCO) responsive to changes in an input signal for changing a frequency of a VCO-output signal from said voltage-controlled oscillator, an in-phase mixer coupled to an input for generating an in-phase-baseband signal from a received-spread-spectrum signal at the input, a quadrature-phase mixer coupled to the input for generating a quadrature-phase-baseband signal from the received spread-spectrum signal at the input, an in-phase-matched filter coupled to said in-phase mixer for removing a chipping sequence from the in-phase-baseband signal, thereby generating an in-phase-detected signal, a quadrature-phase-matched filter coupled to said quadrature-phase mixer for removing the chipping sequence from the quadrature-phase-baseband signal, thereby generating a quadrature-phase-detected signal, the improvement comprising:first generating means, coupled to said in-phase-matched filter, for generating an in-phase-sign signal from the in-phase-detected signal; second generating means, coupled to said quadrature-phase-matched filter, for generating a quadrature-phase-sign signal from the quadrature-phase-detected signal; third generating means, operatively coupled to said first generating means and to said second generating means, responsive to the in-phase-sign signal and to the quadrature-phase-sign signal having same signs for outputting a first error signal; a gain control circuit, operatively coupled to said third generating means, responsive to the first error signal for increasing the first error signal; a register, operatively coupled to an output of said third generating means, for storing a first previous error signal from said third generating means, with the first previous error signal previously occurring in time with respect to the first error signal; an EXCLUSIVE-NOR gate, having a first input operatively coupled to an output of said third generating means, a second input operatively coupled to an output of said register, responsive to the first error signal from said third generating means and the first previous error signal stored in said register having a same value, for outputting a first value, and responsive to the first error signal from said third generating means and a first previous error signal stored in said register having a different value, for outputting a second value; and a low pass filter, coupled to the output of said EXCLUSIVE-NOR gate and to said gain control circuit, for averaging a plurality of first values and second values, thereby generating a first averaged value; and said gain control circuit, responsive to the first averaged value increasing, for increasing the gain of said gain control circuit, said gain control circuit, responsive to the first averaged value decreasing, for decreasing the gain of said gain control circuit.
 6. The Costas loop as set forth in claim 5, wherein:said third generating means, responsive to the in-phase-sign signal and to the quadrature-phase-sign signal having different signs, for outputting a second error signal; said gain control circuit, operatively coupled to said third generating means, responsive to the second error signal for decreasing the second error signal; said register for storing a second previous error signal from said third generating means, with the second previous error signal previously occurring in time with respect to the second error signal; said EXCLUSIVE-NOR gate, responsive to the second error signal from said third generating means and the previous second error signal stored in said register having a same value, for outputting a third value, and responsive to the second error signal from said third generating means and the second previous error signal stored in said register having a different value, for outputting a fourth value; and said low pass filter for averaging a plurality of third values and fourth values, thereby generating a second averaged value; and said gain control circuit, responsive to the second averaged value increasing, for increasing the gain of said AGC amplifier, said AGC amplifier, responsive to the second averaged value decreasing, for decreasing the gain of said AGC amplifier.
 7. A method using a Costas loop having a voltage-controlled oscillator coupled to an automatic-gain-control (AGC) circuit said voltage-controlled oscillator responsive to changes in an AGC signal for changing a frequency of an output signal from said voltage-controlled oscillator, an in-phase mixer coupled to an input for generating an in-phase-baseband signal from a received-spread-spectrum signal at the input, a quadrature-phase mixer coupled to the input for generating a quadrature-phase-baseband signal from the received-spread-spectrum signal at the input, an in-phase-matched filter coupled to said in-phase mixer for removing a chipping sequence from the in-phase-baseband signal, thereby generating an in-phase-detected signal, a quadrature-phase-matched filter coupled to said quadrature-phase mixer for removing the chipping sequence from the quadrature-phase-baseband signal, thereby generating a quadrature-phase-detected signal, the method comprising the steps of:generating an in-phase-sign signal from the in-phase-detected signal; generating a quadrature-phase-sign signal from the quadrature-phase-detected signal; generating an error signal in response to the in-phase sign signal and the quadrature-phase-sign signal having same signs; comparing the error signal to a previously stored value of an error signal from the register to generate a comparison value; averaging a plurality of comparison values to generate an averaged value; increasing, in response to the averaged value increasing above a first threshold, an AGC gain of a gain control circuit thereby increasing the AGC signal; and decreasing, in response to the averaged value decreasing below a second threshold, the AGC gain of the gain control circuit, thereby decreasing the AGC signal.
 8. A method using a Costas loop having a voltage-controlled oscillator coupled to an automatic-gain-control (AGC) circuit said voltage-controlled oscillator responsive to changes in an AGC signal for changing a frequency of an output signal from said voltage-controlled oscillator, an in-phase mixer coupled to an input for generating an in-phase-baseband signal from a received-spread-spectrum signal at the input, a quadrature-phase mixer coupled to the input for generating a quadrature-phase-baseband signal from the received-spread-spectrum signal at the input, an in-phase-matched filter coupled to said in-phase mixer for removing a chipping sequence from the in-phase-baseband signal, thereby generating an in-phase-detected signal, a quadrature-phase-matched filter coupled to said quadrature-phase mixer for removing the chipping sequence from the quadrature-phase-baseband signal, thereby generating a quadrature-phase-detected signal, the method comprising the steps of:generating an in-phase-sign signal from the in-phase-detected signal; generating a quadrature-phase-sign signal from the quadrature-phase-detected signal; generating an error signal in response to the in-phase-sign signal and the quadrature-phase-sign signal having different signs; comparing the error signal to a previously stored value of an error signal from the register to generate a comparison value; averaging a plurality of comparison values to generate an averaged value; and increasing, in response to the averaged value increasing above a threshold, an AGC gain of a gain control circuit operatively coupled to an output of the EXCLUSIVE-NOR gate, thereby increasing the AGC signal.
 9. An improved Costas loop with automatic gain control, comprising:a voltage-controlled oscillator (VCO) for changing, responsive to changes in an input signal, a frequency of a VCO-output signal; an in-phase mixer coupled to an input for generating an in-phase-baseband signal from a received-spread-spectrum signal at the input; a quadrature-phase mixer coupled to the input for generating a quadrature-phase-baseband signal from the received-spread-spectrum signal at the input; an in-phase-matched filter coupled to said in-phase mixer for removing a chipping sequence from the in-phase-baseband signal, thereby generating an in-phase-detected signal; a quadrature-phase-matched filter coupled to said quadrature-phase mixer for removing the chipping sequence from the quadrature-phase-baseband signal, thereby generating a quadrature-phase-detected signal; an in-phase limiter, operatively coupled to said in-phase-matched filter, for generating an in-phase-sign signal from the in-phase-detected signal, with the in-phase-sign signal representing a polarity of the in-phase-detected signal; a quadrature-phase limiter, operatively coupled to said quadrature-phase-matched filter, for generating a quadrature-phase-sign signal from the quadrature-phase-detected signal, with the quadrature-phase-sign signal representing a polarity of the quadrature-phase-detected signal; an EXCLUSIVE-OR gate, operatively coupled to said in-phase limiter and to said quadrature-phase limiter, for exclusive-ORing the in-phase-sign signal with the quadrature-phase-sign signal and, responsive to the in-phase-sign signal and the quadrature-phase-sign signal having same signs, for outputting a first error signal, and, responsive to the in-phase-sign signal and the quadrature-phase-sign signal having different signs, for outputting a second error signal; an automatic-gain-control (AGC) circuit, operatively coupled to said EXCLUSIVE-OR gate and to said voltage-controlled oscillator, responsive to the first error signal for increasing the first error signal, responsive to the second error signal for decreasing the second error signal; a register, operatively coupled to an output of said EXCLUSIVE-OR gate, for storing any of the first error signal and the second error signal from said EXCLUSIVE-OR gate; and an EXCLUSIVE-NOR gate, having a first input operatively coupled to an output of said EXCLUSIVE-OR gate, a second input operatively coupled to an output of said register, responsive to the first error signal from said EXCLUSIVE-OR gate and a previous error signal stored in said register having a same value, for outputting a first value, and responsive to the first error signal from said EXCLUSIVE-OR gate and the previous error signal stored in said register having a different value, for outputting a second value; a low pass filter, coupled to the output of said EXCLUSIVE-NOR gate and to said AGC circuit, for averaging a plurality of first values and second values outputted by said EXCLUSIVE-NOR gate to generate an averaged value, and in response to the averaged value increasing above a threshold, increasing the gain of the AGC circuit; and said voltage-controlled oscillator, responsive to an output of said AGC circuit, for changing a frequency of the VCO-output signal.
 10. The improved Costas loop as set forth in claim 9, said EXCLUSIVE-NOR gate, responsive to the second error signal from said EXCLUSIVE-OR gate and a previous error signal stored in said register having a same value, for outputting the first value, and responsive to the second error signal from said EXCLUSIVE-OR gate and the previous error signal stored in said register having a different value, for outputting the second value; andsaid low pass filter, coupled to the output of said EXCLUSIVE-NOR gate and to said AGC circuit, for averaging a plurality of first values and second values outputted by said EXCLUSIVE-NOR gate to generate an averaged value, and in response to the averaged value decreasing below the threshold, decreasing the gain of the AGC circuit. 